<?php
session_start();
include_once 'core/function.general.php';
include_once 'core/url.conf.php';
include_once 'core/dbconnect.php';
include_once 'core/function.rest.gallery.php';
$rid = $_GET['rid'];

$sql = new ownedsql;
$sql->connect();
$sql->query("SELECT rType FROM 3i_rest WHERE rid='$rid'");
$mode = mysql_fetch_array($sql->query);
$mode = $mode['rType'];

//Az ingatlan specifikus lekérdezéshez az oszlopok nevei
switch ($mode) {
    case '1': //lakás
        $queryArray = array("rid", "3i_rest.uid", "sName", "fName", "email", "phone",
            "rPrice", "rCity", "cityName", "rDist", "dName", "rPlace", "rPlaceType",
            "rAdText", "rType", "rTypeName", "rSubType", "rBaseSize", "rFullRooms",
            "rHalfRooms", "rState", "rStories", "rFloor", "rHeating", "rComfort", "rLift",
            "rParking", "rView", "rCommon", "rRoof");
        break;
}

//oszlop lista generálása a lekérdezéshez, fontos odafigyelni a vesszőkre

$sqlCols = "";
$i = 0;
$counter = count($queryArray);
foreach ($queryArray as $item) {
    if (($counter - 1) == $i) {
        $sep = " ";
    } else {
        $sep = ", ";
    }
    $sqlCols .= $item . $sep;
    $i++;
}

//lekérdezés
$sql->query("SELECT " . $sqlCols .
    " FROM 3i_rest LEFT JOIN 3i_userdetails ON 3i_userdetails.uid=3i_rest.uid LEFT JOIN 3i_rest_types ON 3i_rest_types.rTypeID=3i_rest.rType LEFT JOIN 3i_cities ON 3i_cities.cityid=3i_rest.rCity LEFT JOIN 3i_bp_district ON 3i_bp_district.did=3i_rest.rDist WHERE rid='$rid'");
$result = $sql->query;
$sql->kill();

//kerület helyének a megoldása nem főváros esetén
$item = mysql_fetch_array($result);
if ($item['rCity'] == 1) {
    $district = $item['dName'] . "., ";
} else {
    $district = "";
}



?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="hu" lang="hu">

<head>
	<?php generalHeader(); ?>
    <link rel="stylesheet" type="text/css" href="css/rest.css" />
    <link rel="shortcut icon" type="image/x-icon" href="imgs/favicon.ico" />
    <script type="text/javascript" src="script/jquery-1.6.2.min.js"></script>
    <link rel="stylesheet" type="text/css" href="script/shadow/shadowbox.css" />
    <script type="text/javascript" src="script/shadow/shadowbox.js"></script>
    <script type="text/javascript">
        Shadowbox.init();
    </script>
    <script type="text/javascript" src="https://apis.google.com/js/plusone.js">
        {lang: 'hu'}
    </script>

	<title>Ideális Ingatlan Iroda Kft. - ref.: <?php echo $rid; ?></title>
    
    <?php
include_once 'core/function.google.php';
?>
</head>

<body>
    <div id="wrapper">
        <div id="content">
            <div id="col1">
                <img src="imgs/logo_vert.png" />
                <div id="Agent">
                    <div id="img"><img src="<?php
$img = $upload . "images/profile/" . $item['uid'] . "/thumb.jpg";
if (file_exists($img)) {
    echo "core/function.pimage.download.php?uid=" . $item['uid'];
} else {
    echo "imgs/blank-user.jpg";
}
?>" /></div>
                    <div id="text">
                        <span id="cardName"><?php echo $item['sName'] . " " . $item['fName'] ?></span><br />
                        <?php echo $item['phone']; ?><br />
                        <?php echo safeEmailForRest($item['email']) ?><br />
                    </div>
            </div>
            </div>
            <div id="col2">
                <div id="restInfoContainer">
                <?php
switch ($mode) {
    case '1': //lakás

?>
        <fieldset id="restDetails">
                        <legend>Ingatlan adatok</legend>
                        <table>
                            <tr><td id="label">Kategória:</td><td><?php echo $item['rTypeName'] ?></td><td id="label">Típus:</td><td><?php echo
        $item['rSubType'] ?></td></tr>
                            <tr><td id="label">Állapot:</td><td><?php echo $item['rState'] ?></td><td id="label">Ár:</td><td><?php echo
            $item['rPrice'] ?> mFt</td></tr>
                            <tr><td id="label">Közös ktg.:</td><td><?php echo $item['rCommon'] ?> eFt</td><td id="label">Cím:</td><td><?php echo
            $item['cityName'] . ", " . $district . " " . $item['rPlace'] . " " . $item['rPlaceType'] ?></td></tr>
                            <tr><td id="label" colspan="2"></td><td id="label">Szintek:</td><td><?php echo
            $item['rStories'] ?></td></tr>
                            <tr><td id="label">Emelet:</td><td><?php echo $item['rFloor'] ?></td><td id="label">Alapterület:</td><td><?php echo
            $item['rBaseSize'] ?> m<sup>2</sup></td></tr>
                            <tr><td id="label">Szobák:</td><td><?php echo $item['rFullRooms'] .
            " + " . $item['rHalfRooms'] ?> félszoba</td><td id="label">Tetőtéri:</td><td><?php echo
            $item['rRoof'] ?></td></tr>
                            <tr><td id="label">Fűtés:</td><td><?php echo $item['rHeating'] ?></td><td id="label">Komfort:</td><td><?php echo
            $item['rComfort'] ?></td></tr>
                            <tr><td id="label">Lift:</td><td><?php echo $item['rLift'] ?></td><td id="label">Parkolás:</td><td><?php echo
            $item['rParking'] ?></td></tr>
                            <tr><td id="label">Kilátás:</td><td><?php echo $item['rView'] ?></td><td id="label" colspan="2"></td></tr>
                            <tr><td id="label">Hírdetés:</td><td colspan="3"><?php echo
            nl2br($item['rAdText']) ?></td></tr>
                        </table>
                    </fieldset>
        <?php
        break;
}
?>                  <div id="socialBar"><g:plusone size="medium"></g:plusone><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="<?php echo curPageURL(); ?>" send="true" width="450" show_faces="true" colorscheme="dark" font="verdana"></fb:like></div>
                </div> <!-- restInfoContainer vége -->
                <fieldset id="galleryContainer">
                    <legend>Képek</legend>
                    <?php
genGallery($rid)
?>
                    
                </fieldset>
            </div> <!-- col2 vége -->
        </div><!-- content vége -->
        <?php
        footer();
        ?>
    </div>
</body>
</html>